package com.gxm.练习;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import lombok.Data;
import org.junit.Test;

import java.util.*;

public class demo {
    @Test
    public void test01(){
        long now = System.currentTimeMillis();
        for (int j = 0; j < 30; j++) {
            new Thread();
            Map<Integer, Map<Integer, Hl>> wdlxtjMap = new HashMap<>();

            //每个省300个网点
            for (int n = 0; n < 300; n++) {
                //每个网点发往500个省区
                Map<Integer, Hl> lxgstjMap = new HashMap<>();
                for (int i = 0; i < 500; i++) {
                    Hl hl = new Hl();
                    hl.setJrhl(100);
                    hl.setJrjs(100);
                    hl.setJrps(100);
                    hl.setYljhl(100);
                    hl.setYljjs(100);
                    hl.setYljps(100);
                    hl.setZrhl(100);
                    hl.setZrjs(100);
                    hl.setZrps(100);
                    lxgstjMap.put(i, hl);
                }
                wdlxtjMap.put(n,lxgstjMap);
            }
            Hl hlSum = new Hl();
            hlSum.setJrhl(100);
            hlSum.setJrjs(100);
            hlSum.setJrps(100);
            hlSum.setYljhl(100);
            hlSum.setYljjs(100);
            hlSum.setYljps(100);
            hlSum.setZrhl(100);
            hlSum.setZrjs(100);
            hlSum.setZrps(100);
            for (int n = 0; n < 300; n++) {
                Map<Integer, Hl> lxgstjMap = wdlxtjMap.get(n);
                for (int i = 0; i < 500; i++) {
                    //System.out.println(lxgstjMap.get(i));
                    hlSum.setZrps(hlSum.getZrps() + lxgstjMap.get(i).getZrps());
                    hlSum.setZrhl(hlSum.getZrhl() + lxgstjMap.get(i).getZrhl());
                    hlSum.setZrjs(hlSum.getZrjs() + lxgstjMap.get(i).getZrjs());
                    hlSum.setYljps(hlSum.getYljps() + lxgstjMap.get(i).getYljps());
                    hlSum.setYljjs(hlSum.getYljjs() + lxgstjMap.get(i).getYljjs());
                    hlSum.setYljhl(hlSum.getYljhl() + lxgstjMap.get(i).getYljhl());
                    hlSum.setJrps(hlSum.getJrps() + lxgstjMap.get(i).getJrps());
                    hlSum.setJrjs(hlSum.getJrjs() + lxgstjMap.get(i).getJrjs());
                    hlSum.setJrhl(hlSum.getJrhl() + lxgstjMap.get(i).getJrhl());
                }
            }
            System.out.println(hlSum);
        }

        System.out.println("耗时:" + (System.currentTimeMillis() - now));
    }

    @Test
    public void test02(){
        JSONObject jsonObject = new JSONObject();
        System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
        Hl hl = new Hl();
        HlVo hlVo = new HlVo();
        List<Hl> hlVos = new ArrayList<>();
        hlVos.add(hlVo);
        jsonObject.put(Thread.currentThread().getStackTrace()[1].getMethodName(), hlVos.get(0).getJrhl());
        System.out.println(jsonObject.get(Thread.currentThread().getStackTrace()[1].getMethodName()));
    }

    private  List<HlVo> test03(){
        List<HlVo> hlVos = new ArrayList<>();
        Hl hl = new Hl();
        hl.setJrhl(1);
        return hlVos;
    }

    @Test
    public void test04(){
        Map<String,String> map = new HashMap<>();
        map.put("1","1");
        map.put("2","2");
        map.forEach((key,value) -> {
            map.put(key,value + "1");
        });
        System.out.println(map);
    }


    @Test
    public void test05(){
        Hl hl = new Hl();
        hl.setJrhl(1);
        zcd(hl);
        System.out.println(hl.getJrhl());
    }
    @Test
    public void test06(){
        Map map = new HashMap();
        map.forEach((key, value) -> {
            System.out.println(key);
        });
    }

    @Test
    public void test07(){
        System.out.println(new Date("2021-12-18 08:00:02"));
    }
    private void zcd(Hl hl){
        hl.setJrhl(2);
    }
}

@Data
class Hl{
    //昨日 货量,票数,件数
    private Integer zrhl;
    private Integer zrps;
    private Integer zrjs;
    //今日 货量,票数,件数
    private Integer jrhl;
    private Integer jrps;
    private Integer jrjs;
    //当前月累计 货量,票数,件数
    private Integer yljhl;
    private Integer yljps;
    private Integer yljjs;
}
@Data
class HlVo extends  Hl{
    private Integer status;
}